// home 模块仓库 vuex~
import {requestCategoryList} from "@/api/index.js";
import {requestBannerList} from "@/api/index.js";
import {requestFloorList} from "@/api/index.js";

const actions = {
  // 通过API里面的接口函数调用，向服务器发请求，获取数据
  async categoryList({commit}) {
    let xml = await requestCategoryList();
    if(xml.data.code) {
      commit("CATEGORYLIST", xml.data);
    }    
  },

  // mock banner
  async bannerList({commit}) {
    let xml = await requestBannerList();
    if(xml.data.code === 200) {
      commit("BANNERLIST", xml.data);
    };    
  },

  // mock floor
  async floorList({commit}) {
    let xml = await requestFloorList();
    if(xml.data.code === 200) {
      commit("FLOORLIST", xml.data);
    }    
  }
};
const mutations = {  
  CATEGORYLIST(state, value) {
    state.categoryList = value;    
  },
  BANNERLIST(state, value) {
    state.getBannerList = value;
  },
  FLOORLIST(state, value) {
    state.floorList = value;
  },
};
const state = {
  categoryList: null,
  getBannerList: null,
  floorList: null,
};

const getters = {};
export default {
  actions,
  mutations,
  state,
  getters,
}
 